<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="../../common/header.jsp"/>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
//新增编辑页面
function toEditParams(id){
	$("#plist_form").attr("action","<%=request.getContextPath() %>/sys/parameter/form");
	$("#hiddenId").val(id);
	$("#plist_form").submit();
}

//删除
function delParams(id,parametername){
	bootbox.dialog({
		message : "<spring:message code="sure you want to delete"></spring:message>"+parametername+"<spring:message code="what"></spring:message>",
		title : "<spring:message code="delete the system param"></spring:message>",
		buttons : {
			confirm : {
				label : '<spring:message code="sure to delete"></spring:message>',
				className : "btn red btn-ok",
				callback : function() {
					$.ajax({
						type : "GET",
						url : "<%=request.getContextPath()%>/sys/parameter/deleteparams?id="+id,
						dataType : 'text',
						async : false,
						success : function(data) {
							if(data=="success"){
								noty({layout: 'top',text: "<spring:message code="delete the system param success"></spring:message>！",type: 'success', timeout: 2000 });
								setTimeout(function(){window.location.reload();}, 1000);
							}else{
								noty({layout: 'top',text: "<spring:message code="delete the system param failure"></spring:message>！",type: 'error', timeout: 2000 });
							}
						},
						error : function(data, status) {
							noty({layout: 'top',text: "<spring:message code="error"></spring:message>！",type: 'error', timeout: 2000 });
						}
					});
				}
			},
			cancel : {
				label : "<spring:message code="cancel"></spring:message>",
				className : "btn btn-danger"
			}
		}
	});
}

//分页
function toListPage(pageIndex){
	$("#plist_form").attr("action","<%=request.getContextPath() %>/sys/parameter/list");
	$("#iDisplayStart").val(pageIndex);
	$("#plist_form").submit();
}

</script>
</head>
<body class="page-header-fixed page-full-width">


	<!-- CONTENT -->
			<form id="plist_form" action="<%=request.getContextPath() %>/sys/parameter/list" method="post">

			<input type="hidden" name="id" id="hiddenId"></input>
			<input type="hidden" name="parametername" id="parameternameId"></input>
            <input type="hidden" name="iDisplayStart" id="iDisplayStart" value=${list.currentPage } />
				<div class="page-content">
				
				<div class="container-fluid">
				
								<p></p>
								
								<div class="row-fluid">
								
								<div class="portlet-body">
				
												<div class="clearfix">
				
													<p class="pull-left">
														
														<a href="#" onclick="toEditParams(null);" class="btn blue" >
				
														<spring:message code="btn.common.add.param"></spring:message><i class="icon-plus"></i>
				
														</a>
													</p>
				
												</div>
												
															
																<spring:message code="param value"></spring:message>:<div class="input-append hidden-phone">  
				
																	<input class="m-wrap medium" size="10" name="searchValue" value="${searchValue }" type="text" />
																	<button class="btn red"><spring:message code="btn.common.check"></spring:message></button>
																</div>
				
												<table class="table table-striped table-bordered table-hover" id="parameter_grid">
													<thead>
														<tr>
															<th><spring:message code="param name"></spring:message></th>
															<th><spring:message code="param value"></spring:message></th>
															<th><spring:message code="param category"></spring:message></th>
															<th><spring:message code="enabled"></spring:message></th>
															<th><spring:message code="note one"></spring:message></th>
															<th><spring:message code="note two"></spring:message></th>
															<th><spring:message code="note three"></spring:message></th>
															<th><spring:message code="operation"></spring:message></th>
														</tr>
				
													</thead>
													<tbody>
														<c:forEach items="${list.resultList}" var="item" varStatus="status">
														<tr class="odd gradeX">
															<td>${item.parametername }</td>
															<td>${item.parametervalue }</td>
															<td>${item.parametercategory }</td>
															<td>
																<c:if test="${item.markstatus==0}"><spring:message code="disable"></spring:message></c:if>
																<c:if test="${item.markstatus==1}"><spring:message code="enabled"></spring:message></c:if>
															</td>
															<td>${item.note1 }</td>
															<td>${item.note2 }</td>
															<td>${item.note3 }</td>
															<td>
																<a  href="#" onclick="toEditParams(${item.sysParameterId});" class="btn mini blue"><spring:message
																code="btn.common.edit"></spring:message></a>
																	<a onclick="delParams(${item.sysParameterId},'${item.parametername}');" href="#"  class="btn mini red" ><spring:message
																code="btn.common.delete"></spring:message></a>
															</td>
				
														</tr>
														</c:forEach>
													</tbody>
													
												</table>
							<!-- 分页 -->
							<c:if test="${list.totalPages>1}">
								<div class="pagination" style="float: right">
									<ul>
										<li><a href="javascript:void();"><spring:message
														code="total"></spring:message>：${list.totalRows}</a></li>
										<li
											<c:if test="${list.currentPage==1}">class="disabled"</c:if>>
											<c:if test="${list.currentPage>1}">
												<a href="javascript:toListPage(${list.currentPage-1});"><spring:message
														code="previous page"></spring:message></a>
											</c:if> <c:if test="${list.currentPage==1}">
												<a href="#"><spring:message
														code="previous page"></spring:message></a>
											</c:if>
										</li>
										<c:forEach begin="1" end="${list.totalPages}" var="item">
											<c:if
												test="${item < 4 || item==list.currentPage || item==list.currentPage+1 || item==list.currentPage+2 || item + 3 > list.totalPages }">
												<li
													<c:if test="${list.currentPage==item }">class="active"</c:if>><a
													href="javascript:toListPage(${item});">${item}</a></li>
											</c:if>
										</c:forEach>
										<li
											<c:if test="${list.currentPage==list.totalPages}">class="disabled"</c:if>>
											<c:if test="${list.currentPage==list.totalPages}">
												<a href="#"><spring:message
														code="next page"></spring:message> </a>
											</c:if> <c:if test="${list.currentPage!=list.totalPages}">
												<a href="javascript:toListPage(${list.currentPage+1})"><spring:message
														code="next page"></spring:message>
												</a>
											</c:if>
										</li>
									</ul>
								</div>
							</c:if>
						</div>
								
								</div>
				
				</div>
				
				</div>
				
				
				</form>
	<!-- CONTENT END-->



</body>
</html>